"""voteapp URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/2.2/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
from rest_framework.routers import DefaultRouter, SimpleRouter

from polls.views import praise_or_criticize, login, logout, captcha, \
    get_mobile_code, show_index, SubjectViewSet, TeacherViewSet

urlpatterns = [
    path('', show_index),
    # path('subjects/', show_subjects),
    # path('teachers/', show_teachers),
    path('captcha/', captcha),
    path('mcode/<str:tel>/', get_mobile_code),
    path('login/', login),
    path('logout/', logout),
    path('praise/', praise_or_criticize),
    path('criticize/', praise_or_criticize),
    path('jet/', include('jet.urls', 'jet')),
    path('admin/', admin.site.urls),
]

# 创建一个默认路由器对象
router = SimpleRouter()
# 通过默认路由器对象注册视图集
router.register('subjects', SubjectViewSet)
router.register('teachers', TeacherViewSet)
# 获取路由器中的URL合并到urlpatterns中
urlpatterns += router.urls
